<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
   If Not Page.IsPostBack Then
	BindData
   End If
End Sub
Sub BindData()
Dim strConn as string = _
ConfigurationSettings.appSettings("conn")
Dim strSQL as string = "Select ItemID," & _ 
 " ItemName from tblItems"
  Dim myConn As New SQLConnection(strConn)
  Dim myDataReader as SQLDataReader
  Dim Cmd as New SQLCommand(strSQL , myConn)
  myConn.Open()
  myDataReader=Cmd.ExecuteReader( _
  system.data.CommandBehavior.CloseConnection)
  MyDataGrid.DataSource = myDataReader
  MyDataGrid.DataBind()
  myConn.close
End Sub
</script>
<html>
<head>
<title>DataGrid Control</title>
<LINK href="/style.css" 
type=text/css rel=stylesheet>
</head>
<body><div align="center">
<h2>DataGrid and Properties</h2>
<asp:DataGrid  ID="MyDataGrid"
	Headerstyle-BackColor="Gray"
	Headerstyle-Font-Name="Arial"
	Headerstyle-Font-Size="10"
	Headerstyle-Font-Bold="True" 		
	BorderColor="Black"
	BorderWidth="0"
	GridLines="Both"
	CellPadding="3"
	CellSpacing="1"
	Font-Name="Arial"
	Font-Size="8pt"
	Width="100%" 														
	HeaderStyle-CssClass="row_from_css_file"
	AlternatingItemStyle-BackColor="#e5f4ff"
	AutoGenerateColumns="True" 
	runat="server" >
</asp:DataGrid> 
</div>
</body>
</html>
